package com.yoo.ons.base

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.viewbinding.ViewBinding
import com.chad.library.adapter4.QuickAdapterHelper
import com.yoo.module_base.base.BaseCommonFragment
import com.yoo.module_base.base.BaseViewModel

abstract class BaseVMFragment<Binding : ViewBinding, ViewModel : BaseViewModel>(inflaterBlock: (LayoutInflater, ViewGroup?, Boolean) -> Binding, modelClass: Class<ViewModel>) : BaseCommonFragment<Binding, ViewModel>(inflaterBlock, modelClass) {

    open lateinit var helper: QuickAdapterHelper

    override fun onConCreateViewFrame() {
        mViewModel?.baseCallBack?.observeForever { pair ->
            when (pair.first) {
                BaseViewModel.SHOW_PROGRESS -> {
                    activity?.let {
                        if (pair.second.isNullOrBlank().not()) {
                            showProgressDialog(context = it, text = pair.second)
                        } else {
                            showProgressDialog(it)
                        }
                    }
                }
                BaseViewModel.HIDE_PROGRESS -> {
                    hideProgressDialog()
                }
            }
        }
    }
}